home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / __FOPEN.HDR < prev    next >
Text File  |  1994-04-25  |  3KB  |  126 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _FOpen(cFileName, nMode) --> nHandle
  8.  
  9. PARAMETERS:
  10.  
  11. cFileName : File name to open/create
  12. nMode     : KFO_APPEND   : Append to bottom of file
  13.             KFO_OVERWRITE: Overwrite at Beginning
  14.             KFO_TRUNC    : Truncate to Zero Length and overwrite at beginning
  15.  
  16. SHORT:
  17.  
  18. OS File Open with optional file pointer placements.
  19.  
  20. DESCRIPTION:
  21.  
  22. _FOpen() opens/creates files and positions the file pointer according to
  23. the directive in nMode.  In any case, the specified file is created if it
  24. does not exist.
  25.  
  26. _FOpen() Always opens for Read/Write.
  27.  
  28. _FOpen() returns the file handle of the opened/created file, or -1 if an
  29. error occured.  This can also be tested with FERROR() manually.
  30.  
  31. Return Codes:
  32.  
  33. -1 General File Error (DOS ERROR - Use FERROR() to Check)
  34. -2 Unknown Error - your guess is as good as mine
  35. -3 Either cFileName or nMode was not passed or was NIL
  36. -4 Either nMode was not numeric or cFileName was not character
  37. -5 nMode was out of range (USE KLIPPER.CH KFO_* directives!!!)
  38.  
  39. NOTE:
  40.  
  41.  
  42.  
  43. EXAMPLE:
  44.  
  45. Assuming that NEWFILE.TXT does not exist, all three of the following
  46. are identical in operation:
  47.  
  48. _FOpen("NewFile.TXT",KFO_APPEND)
  49. _FOpen("NewFile.TXT",KFO_OVERWRITE)
  50. _FOpen("NewFile.TXT",KFO_TRUNC)
  51.  
  52. Now, assuming that DATAFILE.TXT exists and has data:
  53.  
  54. nHandle = _FOpen("DataFile.TXT",KFO_APPEND)
  55.  
  56. Appends any data written to nHandle (with standard clipper low level file
  57. functions) to the bottom of the existing file.
  58.  
  59. DATAFILE.TXT CONTAINS:
  60.  
  61. <tof>
  62. LINE111111111111111111111111111111
  63. LINE222222222222222222222222222222
  64. LINE333333333333333333333333333333
  65. <eof>
  66.  
  67. nHandle = _FOpen("DATAFILE.TXT",KFO_APPEND)
  68.  
  69. fwrite(nhandle,"Yow!",4)
  70.  
  71. DATAFILE.TXT -NOW- CONTAINS:
  72.  
  73. <tof>
  74. THIS IS OTHER DATA-TOO.11111111111
  75. LINE222222222222222222222222222222
  76. LINE333333333333333333333333333333Yow!
  77. <eof>
  78.  
  79. _FOpen("DataFile.TXT",KFO_OVERWRITE)
  80.  
  81. Overwrites any data at the beginning of the file, for the length of the
  82. data written, leaving data AFTER that point intact.
  83.  
  84. DATAFILE.TXT CONTAINS:
  85.  
  86. <tof>
  87. LINE111111111111111111111111111111
  88. LINE222222222222222222222222222222
  89. LINE333333333333333333333333333333
  90. <eof>
  91.  
  92. nHandle = _FOpen("DATAFILE.TXT",OVERWRITE)
  93.  
  94. fwrite(nhandle,"THIS IS OTHER DATA",18)
  95. fwrite(nhandle,"-TOO.",4)
  96.  
  97. DATAFILE.TXT -NOW- CONTAINS:
  98.  
  99. <tof>
  100. THIS IS OTHER DATA-TOO.11111111111
  101. LINE222222222222222222222222222222
  102. LINE333333333333333333333333333333
  103. <eof>
  104.  
  105. _FOpen("DataFile.TXT",KFO_TRUNC)
  106.  
  107. DATAFILE.TXT CONTAINS:
  108.  
  109. <tof>
  110. LINE111111111111111111111111111111
  111. LINE222222222222222222222222222222
  112. LINE333333333333333333333333333333
  113. <eof>
  114.  
  115. nHandle = _FOpen("DATAFILE.TXT",KFO_TRUNC)
  116.  
  117. fwrite(nhandle,"THIS IS OTHER DATA",18)
  118.  
  119. DATAFILE -NOW- CONTAINS:
  120.  
  121. <tof>
  122. THIS IS OTHER DATA
  123. <eof>
  124.  
  125. ******************************************************************************/
  126.